package com.ocom.webapi.controller;


import com.alibaba.fastjson.JSON;
import com.ocom.common.resp.Result;
import com.ocom.common.utils.ResultUtil;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.jwt.JwtHelper;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@PreAuthorize("hasRole('ROLE_WEB')")
@RestController
public class CheckTokenController {

	@GetMapping("/checkToken")
	public Result checkToken(){
		return ResultUtil.success();
	}

	//手动解析token
	public  void parseToken(){
		String token="Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoyMSwidXNlcl9uYW1lIjoiYWRtaW4iLCJwZXJtaXNzaW9ucyI6WyJzeXM6dXNlcjphZG1pbiJdLCJzY29wZSI6WyJhbGwiXSwiaXAiOiIxOTIuMTY4LjExLjI0OSIsImlkIjoxLCJjb21JZCI6MSwiZXhwIjoxNjQ4NTgxNjU3LCJhdXRob3JpdGllcyI6WyJST0xFX1dFQiIsIjIxIl0sImp0aSI6IjUzYzc4OThhLWJhY2MtNDlmMC05ZTNjLTM3ZmQ0MmE4Yzc4NiIsImNsaWVudF9pZCI6ImNsaWVudF8xIn0.LOIXSqTvO8U8ERBXw6lmzeP_tdTbz1rEbgiQYVqnuTYSX8JL0IGdSsFGH1wKQBmcRKlHjPhlsMDBiSFpuP7gJS0eYovt7Bi6lrdpGmF80_YNbazMFNeWfHM-jfduCbVIKu3lNdGvfHxwBsb9iUhHIfZo3K3aM7GiaxLV-C6Vpb2AVFd6g9LjWHviXRkg1xlnNL-0cURfFa7VrjvtlAweX-L8ccJMK0ZLZuOURdWv8tCk7zPU299yoCiEMGIkJzh7J3vjLF7CWIFStQU04SbkyPNtg77b_SbTvpIUujWs5QC5P7rBDdMQkAM3Nz8ZzOpDirJYQRD5pcv0BxidLSCDVw";
		String jsonMap= JwtHelper.decode(token).getClaims();
		Map<String,Object> config = JSON.parseObject(jsonMap, HashMap.class);
	}


}
